package com.example.musicdemo.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast


abstract class  BaseActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())

        initListener()

        initData()

    }

     protected open fun initData(){}

     protected open fun initListener(){}

     abstract fun getLayoutId(): Int


     protected fun myToast(msg:String){
         runOnUiThread {
             toast(msg)
         }

     }

    /**
     * 开始另外活动，结束当前活动
     */
    inline fun <reified T : BaseActivity>startAndFinishActivity(){
        startActivity<T>()
        finish()
    }
}